﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using HR60_PanelSoft.View;
using System.Runtime.InteropServices;

namespace HR60_PanelSoft
{

    //GC: [g1]调用-调用控制台[Program]
    //GC: [g2]调用-嵌入控制台[Program]
    //GC: [g3]独立进程检测[Program]
    static class Program
    {
        /* [g2.s1] */
        /* [g1.s1]调用api */

        //[DllImport("kernel32.dll")]
        //static extern bool FreeConsole();

        //[DllImport("kernel32.dll")]
        //static extern bool AllocConsole();
        /* end of [g1.s1] */
        /* end of [g2.s1] */
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            /* [g2.s1] */
            /* [g1.s2] 调用控制台 */
            ////Application.SetCompatibleTextRenderingDefault(false);
            ////Application.Run(new WindowMain());
            //AllocConsole();
            ////Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new WindowMain());
            //FreeConsole();
            /* [g3.s1] 启动程序之前，需要检测是否已经存在进程【HR60_PanelSoft.exe】*/
            if (System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1)
            {
                View.ViewUtils.showAlert("打开失败：有相同程序正在运行！");
                Environment.Exit(Environment.ExitCode);/*如果存在相同进程，则自杀！*/
            }

            /* end of [g3.s1] */

            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new WindowMain());
            /* end of [g1.s2] */

            /* end of [g2.s2] */
        }
    }
}
